package com.wzl.customviewproject.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.wzl.customviewproject.fragment.TestFragmentOne;
import com.wzl.customviewproject.fragment.TestFragmentSecond;
import com.wzl.customviewproject.fragment.TestFragmentThird;

import org.jetbrains.annotations.NotNull;

/**
 * 作者：longxiansen
 * 功能：
 */
public class FragmentsAdapter extends FragmentStateAdapter {
    String[] tabs = new String[]{"关注", "推荐", "最新"};

    public FragmentsAdapter(@NonNull @NotNull FragmentManager fragmentManager, @NonNull @NotNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);
    }

    @NonNull
    @NotNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return TestFragmentOne.newInstance();
            case 1:
                return TestFragmentSecond.newInstance();
            case 2:
                return TestFragmentThird.newInstance();
        }
        return TestFragmentOne.newInstance();
    }

    @Override
    public int getItemCount() {
        return tabs.length;
    }
}
